﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Resxus.Model;


namespace Resxus.DataAccess
{
    /// <summary>
    /// 데이터가 변경되었음을 통지하는 클래스
    /// </summary>
    public class DataChangedEventArgs<T>
    {
        /// <summary>
        /// 데이터 변경 Action 정의
        /// </summary>
        public enum ChangeAction
        {
            Add,
            Remove,
            Clear,
            Update
        }

        /// <summary>
        /// 변경된 데이터 오브젝트
        /// </summary>
        public T Source
        {
            get;
            private set;
        }

        /// <summary>
        /// 변경 액션
        /// </summary>
        public ChangeAction Action
        {
            get;
            private set;
        }

        /// <summary>
        /// 프로퍼티가 변경되었을 경우 추가정보
        /// </summary>
        public PropertyNotificationEventArgs ChangedProperty
        {
            get;
            private set;
        }

        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="action">변경액션</param>
        public DataChangedEventArgs(ChangeAction action)
        {            
            this.Action = action;
        }

        /// <summary>
        /// 생성자 
        /// </summary>
        /// <param name="source">변경된 데이터 오브젝트</param>
        /// <param name="action">변경 액션</param>
        public DataChangedEventArgs(T source, ChangeAction action)
            : this(action)
        {
            this.Source = source;            
        }

        /// <summary>
        /// 생성자 
        /// </summary>
        /// <param name="source">변경된 데이터 오브젝트</param>
        /// <param name="action">변경 액션</param>
        /// <param name="changedEvenrArgs">프로퍼티가 변경되었을 경우 추가정보</param>
        public DataChangedEventArgs(T source, ChangeAction action, PropertyNotificationEventArgs changedEvenrArgs)            
            : this(source, action)
        {            
            this.ChangedProperty = changedEvenrArgs;
        }
    }
}
